#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <strings.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>


int main()
{
    int fd = socket(AF_INET, SOCK_STREAM, 0);
    if (fd < 0) {
        perror("Client socket error");
        return -1;
    }

    struct sockaddr_in addr;
    bzero(&addr, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = inet_addr("127.0.0.1");
    addr.sin_port = htons(8080);

    int n = connect(fd, (struct sockaddr*)&addr, sizeof(addr));
    if (n < 0) {
        perror("connect error");
        return -2;
    }

    while (1) {

        char buffer[128] = {0};
        fgets(buffer, 128, stdin);
        send(fd, buffer, strlen(buffer), 0);
    }

    close(fd);

    return 0;
}